#ifndef __SERVO__
#define __SERVO__

#include "stm32f10x.h"
#include "stm32f10x_conf.h"

/* Maximum angle 180 in 1/100 of degree */ 
#define MAX_ANGLE       18000
/* Max angle speed (180*3 degrees per second) */
#define MAX_ANGLE_SPEED (18000*3)
/* Angle step - 0.1 degree */
#define ANGLE_STEP      100
#define ANGLE_DELTA     ANGLE_STEP

/* Angle from 0 to 180 degrees: duty from 550us to 2200us */
#define ANGLE_0_DUTY_US    550
#define ANGLE_180_DUTY_US  2200
#define PERIOD_50HZ        20000

void PWM_Configuration_50Hz(TIM_TypeDef* TIMx);
/* Set servo position at max speed */
int SetServoMax(int channel, int angle);
/* Set servo position at specified speed */
int SetServo(int channel, int angle, int speed);
/* Get servo position */
int GetServo(int channel);

#endif

